<template>
	<view class="countPrice" style="width: 80%; margin:0 auto;" >
		<view class="top">
			<view>
				年份：
				<el-select v-model="queryParams.year" placeholder="请选择年份">
					<el-option v-for="(item, index) in yearList" :label="item.label" :value="item.value"></el-option>
				</el-select>
			</view>
			<view style="margin-left: 100rpx;">
				<el-button type="primary" @click="getList">搜索</el-button>
			</view>
		</view>
		<uni-table style="margin-top: 40rpx;" :stripe="false" border emptyText="暂无更多数据" >
			<!-- 表头行 -->
			<uni-tr>
				<uni-th class="tab-header" align="center">月份</uni-th>
				<uni-th class="tab-header" align="center">工资</uni-th>
			</uni-tr>
			<!-- 表格数据行 -->
			<uni-tr  v-for="(item, index) in tableData" :key="index">
				<uni-td class="tab-data" align="center">{{item.months}}</uni-td>
				<uni-td class="tab-data" align="center" style="color:#6DB4E2">{{item.money}}</uni-td>
			</uni-tr>
		</uni-table>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				tableData:{},
				queryParams:{
					year: new Date().getFullYear()
				}
			}
		},
		computed: {
			yearList(){
				let yearList = []
				for(var i=2022; i<=new Date().getFullYear(); i++){
					yearList.push({
						label: i,
						value: i
					})
				}
				return yearList
			}
		},
		mounted(){
			this.getList()
		},
		methods:{
			getList(){
				this.api.countPrice({yearStr:this.queryParams.year}).then((res)=>{
					this.tableData = res.data.data
				})
			}
		}
	}
</script>

<style>
	.tab-header{
		background: #42B5FF;
		font-size: 27rpx;
		font-family: Microsoft YaHei;
		line-height: 26rpx;
		color: #FFFFFF;
		opacity: 1;
	}
	.tab-data{
		font-size: 24rpx;
	}
	.countPrice {
		width: 97%;
		margin: 0 auto;
	}
	
	.countPrice .top {
		width: 100%;
		box-sizing: border-box;
		padding: 20rpx;
		background-color: #fff;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		flex-wrap: wrap;
		overflow: scroll;
	
	}
	
	.countPrice .bottom {
		/* width: 100%; */
		background-color: #f5f5f5;
		overflow: auto;
		margin-top: 40rpx;
	}
</style>